<?php
// ==========================================================
// | IntegralOrder
// ==========================================================
// | Time：2021/12/18 21:46
// ==========================================================
// | Author: 陈 <1035812848@qq.com>
// ==========================================================

namespace app\common\validate;

use think\Validate;

class IntegralOrder extends Validate
{
    /**
     * 验证规则
     */
    protected $rule = [
        'region_id'         => 'number',
        'user_id'           => 'require|number',
        'integral_goods_id' => 'require|number',
        'order_no'          => 'require|length:19',
        'title'             => 'require|length:1,50',
        'number'            => 'require|number',
        'name'              => 'require|length:1,20',
        'mobile'            => 'require|regex:^1[0-9]{10}$',
        'address'           => 'require|length:1,255',
        'lng'               => 'require|float',
        'lat'               => 'require|float',
    ];

    /**
     * 提示消息
     */
    protected $message = [
        'region_id.number'      => '订单区域错误',
        'user_id'               => '下单用户不能为空',
        'user_id.number'        => '下单用户错误',
        'integral_goods_id'     => '积分商品错误',
        'order_no'              => '订单编号错误',
        'order_no.length'       => '订单编号长度错误',
        'title'                 => '订单标题错误',
        'title.length'          => '标题长度范围 1~255个字符',
        'number'                => '订单数量错误',
        'name'                  => '姓名不能为空',
        'name.length'           => '姓名长度范围 1~20个字符',
        'mobile'                => '联系电话不能为空',
        'mobile.regex'          => '联系电话格式错误',
        'address'               => '地址不能为空',
        'address.length'        => '地址长度范围 1~255个字符',
        'lng'                   => '地址经度不能为空',
        'lng.float'             => '地址经度格式错误',
        'lat'                   => '地址纬度不能为空',
        'lat.float'             => '地址纬度格式错误',
    ];

    /**
     * 字段描述
     */
    protected $field = [

    ];

    /**
     * 验证场景
     */
    protected $scene = [
        'add'  => ['region_id', 'user_id', 'integral_goods_id', 'order_no', 'title', 'number', 'name', 'mobile', 'address', 'lng', 'lat'],
    ];

}